package com.edu.controller.front;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.edu.entity.Course;
import com.edu.entity.Teacher;
import com.edu.service.CourseService;
import com.edu.service.TeacherService;
import com.edu.utils.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 麦翔盛
 * @description: 前台展示控制类
 * @date 2021/11/10 14:36
 */
@RestController
@CrossOrigin
@RequestMapping("/edu")
public class IndexController {
    @Autowired
    private TeacherService teacherService;
    @Autowired
    private CourseService courseService;

    /**
     * 返回首页8条热门课程
     * 4位名师
     *
     * @return
     */
    @GetMapping("/index")
    public R index(){
        //降序教师id 并获取前4条
        QueryWrapper<Teacher> teacherQueryWrapper = new QueryWrapper<>();

        List<Teacher> teacherList = teacherService.getHotTeacher();

        List<Course> courseList = courseService.getHotCourse();

        return R.success().data("teacherList",teacherList).data("courseList",courseList);

    }
}
